package com.night.administration.controller;

import com.night.administration.feign.StudentFeign;
import com.night.administration.service.TeacherService;
import com.night.common.entity.ResultVo;
import com.night.common.entity.administration.Teacher;
import com.night.common.entity.student.Score;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;

/**
 * @ClassName: TeacherController
 * @Description: //TODO
 * @author: LZJ
 * @date: 2022/10/23-14:15
 * @version: v1.0
 */
@RestController
@RequestMapping("/api/v1/teacher")
public class TeacherController {
    @Resource
    private TeacherService teacherService;
    @Resource
    private StudentFeign studentFeign;


    @PostMapping("/getAll")
    public ResultVo<Teacher> getAllTeacher() {
        return new ResultVo(teacherService.getAll());
    }

    @PostMapping("/add")
    public ResultVo<String> add(@RequestBody Teacher teacher) {
        teacherService.insert(teacher);
        return ResultVo.SUCCESS;
    }

    @PostMapping("/update")
    public ResultVo<String> update(@RequestBody Teacher teacher) {
        teacherService.update(teacher);
        return ResultVo.SUCCESS;
    }

    @PostMapping("/updateScore")
    public ResultVo<String> updateScore(@RequestBody Score score) {
        studentFeign.addScore(score);
        return ResultVo.SUCCESS;
    }
}
